<html>

<head>
    <script>
        /**
         * Instead of directly creating analytics events inside of the iframe,
         * we first set a cookie here that can be later read out when the user
         * visits the RxDB docs page.
         * This prevents us from creating events from non-developers when the dev-mode
         * is accidentally used in production.
         * Also it fixes problems with the origins of the google tag manager.
         */
        const DEV_MODE_EVENT_ID = 'dev_mode_tracking_iframe';
        const searchParams = new URLSearchParams(window.location.search);
        const version = searchParams.get('version');
        const expiryDate = new Date();
        expiryDate.setMonth(expiryDate.getMonth() + 3);
        document.cookie = DEV_MODE_EVENT_ID + "=" + version + ";expires=" + expiryDate.toGMTString() + ';path=/;SameSite=None; Secure';
        const bc = new BroadcastChannel(DEV_MODE_EVENT_ID);
        bc.postMessage({ DEV_MODE_EVENT_ID, version, expiryDate: expiryDate.toGMTString() });
        // console.dir({ DEV_MODE_EVENT_ID, version, expiryDate: expiryDate.toGMTString() })
    </script>
</head>

<body>
    <p>
        This is the page is shown in an iframe when the <a
            href="https://rxdb.info/dev-mode.html"
            target="_blank"
        >Dev Mode</a> of the <a
            href="https://rxdb.info/"
            target="_blank"
        >RxDB JavaScript Database</a> is enabled. Do never enable the dev-mode in production. Do always enable it during
        development.
    </p>
</body>

</html>
